package top.zhuyougu.demo1.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.zhuyougu.demo1.Mapper.UserMapper;
import top.zhuyougu.demo1.pojo.User;

import java.util.List;

@Service
@Slf4j

public class UserService {

    @Autowired
    private UserMapper userMapper;

//    查询所有user
    public List<User> findAll(){
        return userMapper.selectList(new LambdaQueryWrapper<>());
    }
    public List<User>getAll (){
        return userMapper.getAll();
    }
    //分页查询
    public List<User> findPage(int current  ,int pageSize){
        Page<User> page = new Page<>(current,pageSize);
        Page<User> userPage = userMapper.selectPage(page, new LambdaQueryWrapper<>());
        log.info("total:{}",userPage.getTotal());
        log.info("pages:{}",userPage.getPages());
        return userPage.getRecords();
    }
}
